package com.squapsource.project_euler;

import java.util.ArrayList;
import java.util.List;

public class Problem14 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		int maxSize = 0;
		long maxStart = 0;
		List<Long> sequence = null;
		for (int i = 2; i < 1000000; i++) {
			sequence = getSequence(i);
			if (sequence.size() > maxSize)
			{
				maxSize = sequence.size();
				maxStart = sequence.get(0);
			}
		}
		System.out.println(maxSize + " " + maxStart);

	}

	private static List<Long> getSequence(long start) {
		List<Long> sequence = new ArrayList<Long>();
		sequence.add(start);
		while (sequence.get(sequence.size() - 1) != 1) {
			sequence.add(getNextSequence(sequence.get(sequence.size() - 1)));

		}
		return sequence;
	}

	private static Long getNextSequence(Long long1) {
		if (long1 % 2 == 0) {
			return long1 / 2;
		}
		return long1 * 3 + 1;
	}

}
